// pages/city/city.js
import {addCity} from "../../utils/interface"
Page({
  data:{
    username:"",
    mobile:"",
    address:"",
    code:"",
    provinceId:"",
    cityId:""
  },
  //地区
  goCity(e){
    // console.log(e);
    this.data.provinceId =e.detail.code[0]
    this.data.cityId = e.detail.code[1]
     this.setData({
        provinceId:this.data.provinceId,
        cityId:this.data.cityId
      })
  },
  //添加
  async add(){
    let token = wx.getStorageSync('token')
    let {data:res} = await addCity({
      address:this.data.address,
      cityId:this.data.cityId,
      code:this.data.code,
      linkMan:this.data.username,
      mobile:this.data.mobile,
      provinceId:this.data.provinceId,
      token:token
    })
  // console.log(res);
    if(res.code==0){
      wx.reLaunch({
        url: '/pages/address/address',
      })
    }
  }

})